package work729.work1;

public class Student {
  private String Sname;
  private String Sno;//学号
  private int Sage;//年龄
  private String Scollege;//学校
  private int Syear;
  private String Sclass;
  private String Sid;

  public Student() {

  }

  public Student(String sname, int sage, String scollege, int syear, String sclass, String sid) {
    Sname = sname;
    this.setSage(sage);
    Scollege = scollege;
    Syear = syear;
    Sclass = sclass;
    Sid = sid;
  }

  public String getSname() {
    return Sname;
  }

  public void setSname(String sname) {
    Sname = sname;
  }

  public String getSno() {
    String a =this.getSyear()+"";
    String Sno = a+this.getSclass()+this.getSid();
    if (Sno.length()>= 8){
      return Sno;
    }else {
      throw new IllegleSnoException("学位号不能小于8位");
    }
  }

  public int getSage() {
    if (Sage<200&&Sage>0 ){
      return Sage;
    }else {
      throw new IllegleSageException("年龄不能为负数和大于200岁");
    }
  }

  public void setSage(int sage) {
    Sage = sage;
  }

  public String getScollege() {
    return Scollege;
  }

  public void setScollege(String scollege) {
    Scollege = scollege;
  }

  public int getSyear() {
    return Syear;
  }

  public void setSyear(int syear) {
    Syear = syear;
  }

  public String getSclass() {
    return Sclass;
  }

  public void setSclass(String sclass) {
    Sclass = sclass;
  }

  public String getSid() {
    return Sid;
  }

  public void setSid(String sid) {
    Sid = sid;
  }

  public void  printInfor(){
    try {
      System.out.println("学号："+this.getSno()+",姓名："+this.getSname()+",年龄："+this.getSage()+",学校："+this.getScollege());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
   public static void main(String[] args) {
    Student student = new Student("小明",-7,"科海",2020,"69","03");
    student.printInfor();
  }
}
